<template>
    <div>
   <h1>添加</h1>
   <table class="table">
    <thead>
        <tr>
            <td>门店名称</td>
            <td>
                 <input type="text" v-model="data.name">
            </td>
        </tr>
         <tr>
            <td>店长名称</td>
            <td>
                 <input type="text" v-model="data.yonghuname">
            </td>
        </tr>
         <tr>
            <td>手机号码</td>
            <td>
                 <input type="text" v-model="data.phone">
            </td>
        </tr>
         <tr>
            <td>邮件</td>
            <td>
                 <input type="text" v-model="data.email">
            </td>
        </tr>
         <tr>
            <td>照片</td>
            
              <td>
              <input type="file" @change="zhaopian">
              <img :src="'https://localhost:7029'+data.img" style="height: 60px;width: 60px;">
            </td>
        </tr>
         <tr>
            <td></td>
            <td>
                <input type="button" value="提交" @click="tianjia" class="btn btn-success">
            </td>
        </tr>
    </thead>
</table>
    </div>
</template>

<script setup lang="ts">
import axios from 'axios';
import { ref } from 'vue';


const zhaopian=(val:any)=>{
  var a=val.target.files[0];
  var b=new FormData();
  b.append("file",a);
 
  axios.post("/api/mendian/shangchuan",b).then(res=>{
    data.value.img=res.data;
  })
}
const data=ref({
  "id": 0,
  "name": "",
  "yonghuname": "",
  "phone": "",
  "email": "",
  "img": "",
  "isdel": true
})



const tianjia=()=>{
    axios.post("/api/mendian/tinajia",data.value).then(res=>{
        if(res.data>0)
    {
        alert("添加成功")
        location.href='/';
    }
    else{
        alert("添加失败")
    }
    })
}
</script>

<style scoped>

</style>